var models = require('../models');
var _ = require('lodash');

// 通过用户名查找用户
function findByUnameOrPcode(obj) {
  if (obj.uname) {
    return models.user.findOne({
      where: {
        uname: obj.uname
      }
    });
  } else {
    return models.user.findOne({
      where: {
        pcode: obj.pcode
      }
    });
  }
}
exports.findByUnameOrPcode = findByUnameOrPcode;

// 通过uuid查找用户
function findByUUID(uuid) {
  return models.user.findOne({
    where: {
      uuid: uuid
    }
  });
}
exports.findByUUID = findByUUID;

// 通过uuid查找用户，包含已删除的
function findByUUIDIncludeDeleted(uuid) {
  return models.user.findOne({
    where: {
      uuid: uuid
    },
    paranoid: false
  });
}
exports.findByUUIDIncludeDeleted = findByUUIDIncludeDeleted;
